<?php
require_once("{$CfgPara->root}/model/user.m.php");
if (isset($_SESSION['user_id']) && is_numeric($_SESSION['user_id'])) {
    $myUser = new user_m($CfgPara->database);
    $userMsg = $myUser->user_msg('Id', $_SESSION['user_id']);
    if (is_string($userMsg)) {
        echo($userMsg);
        goto page_end;
    }
    $userName = $userMsg->Name;
    $userUrl = "/user/{$userMsg->Id}.html";
    //$userLoginForward = 'controller=user_show&user_id='.$userMsg->Id.'"';
    if (isset($_SESSION['user_admin']) && $_SESSION['user_admin'] == 1 &&
        $userMsg->Level >= 90
    ) {
        $userAvatar = "{$CfgPara->httproot}/avatar/admin.png";
        require("{$viewRoot}user_admin_left_bar{$viewEx}");
    } else {
        $userAvatar = $userMsg->Avatar;
        require("{$viewRoot}user_left_bar{$viewEx}");
    }
    // 如果当前用户已经登陆 则让客户端开启周期性获取是否有未读消息的程序
    // 20170522 当前仅手机端需要
    if ($isTablet === false)
        echo '<script>has_new_start();</script>';
} else {
    $userAvatar = $CfgPara->httproot . '/avatar/default.jpg';
    $userName = '请登录';
    $userUrl = '/user/login/';
    require("{$viewRoot}user_left_bar{$viewEx}");
}

page_end:;